#! /bin/sh
mkdir build -p

#刷新cmake环境
cmake -S . -B build

#cmake编译
cd build
cmake ..
make -j12
make install

#添加版本
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD | sed 's/\//_/g')
DATE=$(TZ='Asia/Shanghai' date "+%Y%m%d")
COMMIT_ID=$(git rev-parse --short=8 HEAD)
TAG=${BRANCH_NAME}_${DATE}_${COMMIT_ID}
echo $TAG > ../out/bin/version.txt

#编译结果打包
cd ..
mkdir install_package -p
cp out/* install_package -a
cp install/* install_package -a
rm -rf install_package.tar.gz
tar -czf install_package.tar.gz install_package
rm install_package -rf